package com.vernhe;

import java.util.LinkedList;

public class Deque<E> {
    private LinkedList list = new LinkedList();

    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void clear() {
        list.clear();
    }

    public void enQueueRear(E element) {
        list.add(element);
    }

    public E deQueueRear() {
        return (E) list.remove(size() - 1);
    }

    public E deQueueFront() {
        return (E) list.remove();
    }

    public void enQueueFront(E element) {
        list.add(0,element);
    }

    public E front() {
        return (E) list.get(0);
    }

    public E rear() {
        return (E) list.get(size() - 1);
    }

    @Override
    public String toString() {
        return list.toString();
    }
}
